<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::group(['namespace' => 'Index'], function () {
    Route::get('/{type?}', 'IndexController@index')->name('index.index')->where(['type' => '[0-9]+']);

    Route::get('brand_list', 'IndexController@brandList');

    Route::get('article_details', 'ArticleController@searchArticle');

    Route::get('user_article_details', 'ArticleController@useArticleDetails');

    Route::get('user', 'UserController@index');

});

//后台路由
Route::group(['prefix'=>'admin', 'namespace' => 'Admin'], function () {

    //登录验证中间件
    Route::group(['middleware' => 'auth'],function(){
        Route::get('index', 'IndexController@index')->name('admin');
        //权限管理资源路由
        Route::resource('menu', 'MenusController');
        //用户组管理资源路由
        Route::resource('admin_group', 'AdminGroupController');
        //后台用户管理资源路由
        Route::resource('admin_user', 'AdminUserController');
        //文章管理资源路由
        Route::resource('articles', 'ArticlesController');
        //前台用户管理资源路由
        Route::get('user', 'UserController@index')->name('admin.user');
        Route::get('be_dealer/{id}', 'UserController@be_dealer')->name('admin.be_dealer');
        //品牌管理资源路由
        Route::resource('brand', 'BrandController');
        //显示和修改网站信息
        Route::match(['get','post'],'web_config','IndexController@webConfig')->name('web_config');
    });

    //上传图片
    Route::post('upload', 'IndexController@upload')->name('upload');

    Route::get('captcha/{tmp}', 'LoginController@captcha');

    Route::match(['get','post'], 'login', 'LoginController@login')->name('admin.login');
    
    Route::get('logout', 'LoginController@logout')->name('admin.logout');

});



Auth::routes();

//Route::get('/home', 'HomeController@index')->name('home');
